import { ProFormColumnsType, ProFormRadio } from '@ant-design/pro-components';
import { Button, Radio } from 'antd';
import { MenuType } from '@/types/menu';
import { MenuOption } from '@/enums/menuType';
import { WitIcon } from '@/components/Icon';

export const menuFormItem: ProFormColumnsType<MenuType>[] = [
  {
    title: '菜单类型',
    dataIndex: 'mode',
    valueType: 'radioButton',
    initialValue: 'A',
    fieldProps: {
      options: MenuOption,
    },
    renderFormItem: () => {
      return <Radio.Group optionType="button" />;
    },
    formItemProps: {
      rules: [
        {
          required: true,
          message: '此项为必填项',
        },
      ],
    },
  },
  {
    title: '菜单名',
    dataIndex: 'name',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '此项为必填项',
        },
      ],
    },
  },
  {
    title: '路由',
    dataIndex: 'path',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '此项为必填项',
        },
      ],
    },
  },
  {
    title: '组件名',
    dataIndex: 'component',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '此项为必填项',
        },
      ],
    },
  },
  {
    title: '排序',
    dataIndex: 'sort',
    formItemProps: {
      rules: [
        {
          required: true,
          message: '此项为必填项',
        },
      ],
    },
  },
  {
    title: '图标',
    dataIndex: 'icon',
    valueType: 'text',
    // @ts-ignore
    render: dom => <WitIcon type={dom} />,
  },
  {
    title: '禁用',
    dataIndex: 'disabled',
    valueType: 'switch',
    initialValue: false,
  },
  {
    title: '是否显示',
    dataIndex: 'hideTab',
    valueType: 'switch',
    initialValue: true,
  },
  {
    title: '是否固定',
    dataIndex: 'affix',
    valueType: 'switch',
    initialValue: false,
  },
  {
    title: '备注',
    dataIndex: 'memo',
    valueType: 'textarea',
  },
];
